<template>
    <div>
        <h2>房号添加</h2>
        <table class="table table-bordered">
            <tr>
                <td align="right">房号</td>
                <td><input type="text" v-model="sate.hName" /></td>
            </tr>
            <tr>
                <td align="right">创建人</td>
                <td><input type="text" v-model="sate.man" /></td>
            </tr>
            <tr>
                <td align="right">房型</td>
                <td><input type="text" v-model="sate.hType" /></td>
            </tr>
            <tr>
                <td align="right">房态</td>
                <td><input type="text" v-model="sate.hState" /></td>
            </tr>
            <tr>
                <td align="right"></td>
                <td><input type="button" value="添加" @click="add" /></td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import { reactive, toRefs } from 'vue';
import axios from 'axios';
import { useRouter, useRoute } from 'vue-router';
let router = useRouter()
let data = reactive({
    sate: {
        hName: "",
        man: "",
        hType: "",
        hState: ""
    }
})
let { sate } = toRefs(data)
const add = () => {
    let obj = {
        hName: sate.value.hName,
        man: sate.value.man,
        hType: sate.value.hType,
        hState: sate.value.hState
    }
    console.log(obj)
    axios({
        url: '/api/HouseNumber/HouseNumberAdd',
        method: 'post',
        data: obj
    })
        .then(res => {
            console.log(res)
            if (res.data.data == 1) {
                alert("登录成功")
                router.push('/list')
            }
            else {
                alert("登录失败")
            }
        })
        .catch(err => {
            console.log(err)
        })
}


</script>

<style scoped></style>